export default {
	queryData(config, targetId, callbackObject) {
		RongIMLib.RongIMClient.connect(config.token, {
			onSuccess: function(userId) {
				RongIMClient.getInstance().getConversationList({
				  	onSuccess: function(list) {
						RongIMLib.RongIMClient.getInstance().getConversation(
							RongIMLib.ConversationType.PRIVATE, targetId, callbackObject);
				  	},
				  	onError: function(error) {
				    	// do something...
				  	}
				}, null);
			},
			onTokenIncorrect: function() {
				console.log('token无效');
			},
			onError: function(errorCode) {
				var info = '';
				switch(errorCode) {
					case RongIMLib.ErrorCode.TIMEOUT:
						info = '超时';
						break;
					case RongIMLib.ErrorCode.UNKNOWN_ERROR:
						info = '未知错误';
						break;
					case RongIMLib.ErrorCode.UNACCEPTABLE_PaROTOCOL_VERSION:
						info = '不可接受的协议queryAll版本';
						break;
					case RongIMLib.ErrorCode.IDENTIFIER_REJECTED:
						info = 'appkey不正确';
						break;
					case RongIMLib.ErrorCode.SERVER_UNAVAILABLE:
						info = '服务器不可用';
						break;
				}
				console.log(errorCode);
			}
		});
	},
	
    
	queryAll(config, callbackObject) {
		RongIMLib.RongIMClient.connect(config.token, {
			onSuccess: function(userId) {
				
			//debugger;
				RongIMClient.getInstance().getConversationList(callbackObject, null);
			},
			onTokenIncorrect: function() {
				console.log('token无效');
			},
			onError: function(errorCode) {
				var info = '';
				switch(errorCode) {
					case RongIMLib.ErrorCode.TIMEOUT:
						info = '超时';
						break;
					case RongIMLib.ErrorCode.UNKNOWN_ERROR:
						info = '未知错误';
						break;
					case RongIMLib.ErrorCode.UNACCEPTABLE_PaROTOCOL_VERSION:
						info = '不可接受的协议版本';
						break;
					case RongIMLib.ErrorCode.IDENTIFIER_REJECTED:
						info = 'appkey不正确';
						break;
					case RongIMLib.ErrorCode.SERVER_UNAVAILABLE:
						info = '服务器不可用';
						break;
				}
				console.log(errorCode);
			}
		});
	},
	
	delete(config, targetId, callbackObject) {
		RongIMLib.RongIMClient.connect(config.token, {
			onSuccess: function(userId) {
				RongIMClient.getInstance().getConversationList({
				  	onSuccess: function(list) {
						RongIMClient.getInstance().removeConversation(
							RongIMLib.ConversationType.PRIVATE, targetId, callbackObject);
				  	},
				  	onError: function(error) {
				    	// do something...
				  	}
				}, null);
			},
			onTokenIncorrect: function() {
				console.log('token无效');
			},
			onError: function(errorCode) {
				var info = '';
				switch(errorCode) {
					case RongIMLib.ErrorCode.TIMEOUT:
						info = '超时';
						break;
					case RongIMLib.ErrorCode.UNKNOWN_ERROR:
						info = '未知错误';
						break;
					case RongIMLib.ErrorCode.UNACCEPTABLE_PaROTOCOL_VERSION:
						info = '不可接受的协议queryAll版本';
						break;
					case RongIMLib.ErrorCode.IDENTIFIER_REJECTED:
						info = 'appkey不正确';
						break;
					case RongIMLib.ErrorCode.SERVER_UNAVAILABLE:
						info = '服务器不可用';
						break;
				}
				console.log(errorCode);
			}
		});
	}
}